package com.sgb.kjwl.view.ui.activity.self.publish;

import android.annotation.SuppressLint;
import android.app.Activity;
import android.app.AlertDialog;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.graphics.Bitmap;
import android.graphics.Color;
import android.os.Bundle;
import android.os.Environment;
import android.os.Handler;
import android.os.Message;
import android.os.SystemClock;
import android.util.Log;
import android.view.View;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.TextView;
import android.widget.Toast;

import androidx.annotation.NonNull;
import androidx.databinding.DataBindingUtil;

import com.bigkoo.pickerview.builder.OptionsPickerBuilder;
import com.bigkoo.pickerview.view.OptionsPickerView;
import com.google.zxing.BarcodeFormat;
import com.google.zxing.EncodeHintType;
import com.google.zxing.WriterException;
import com.google.zxing.common.BitMatrix;
import com.google.zxing.qrcode.QRCodeWriter;


import com.sgb.kjwl.AppActivity;
import com.sgb.kjwl.R;
import com.sgb.kjwl.api.APIManager;
import com.sgb.kjwl.databinding.ActivitySettingBinding;
import com.sgb.kjwl.di.self.DaggerSelfComponent;
import com.sgb.kjwl.di.self.SelfModule;
import com.sgb.kjwl.model.entity.home.RefreshHomeNoticeEVent;
import com.sgb.kjwl.model.entity.self.UrlSelectEntity;
import com.sgb.kjwl.model.entity.user.SettingInfoEntity;
import com.sgb.kjwl.utils.DialogFunction;
import com.sgb.kjwl.utils.DialogHelper;
import com.sgb.kjwl.utils.UpdateUtils;
import com.sgb.kjwl.view.event.ChooseAreaEvent;
import com.swgk.core.event.EventConstant;
import com.sgb.kjwl.view.event.LoginEvent;
import com.sgb.kjwl.view.event.self.MachinePublishEvent;
import com.sgb.kjwl.view.ui.activity.self.AddressActivity;
import com.sgb.kjwl.view.ui.activity.self.SelfQrCodeActivity;
import com.sgb.kjwl.view.ui.activity.self.authentication.AuthActivity;
import com.sgb.kjwl.view.ui.activity.self.shop.CompanyShopInfoActivity;
import com.sgb.kjwl.view.ui.activity.self.userInfo.BankInfoActivity;
import com.sgb.kjwl.view.ui.activity.self.userInfo.ChangeMobileActivity;
import com.sgb.kjwl.view.ui.activity.self.userInfo.ChangePwdActivity;
import com.sgb.kjwl.view.ui.activity.self.userInfo.FeedbackActivity;
import com.swgk.core.dialog.RoundCornerDialog;
import com.sgb.kjwl.viewmodel.self.SettingModel;
import com.sgb.link.utils.Preferences;
import com.swgk.core.base.di.AppComponent;
import com.swgk.core.customview.ItemInputTextView;
import com.swgk.core.util.CheckUtils;
import com.im.immodel.IMUtils;
import com.swgk.core.util.MToast;
import com.swgk.core.util.ScreenUtil;
import com.swgk.core.util.SharedPreferenceUtil;
import com.swgk.core.util.StringUtil;

import org.greenrobot.eventbus.EventBus;

import java.io.File;
import java.text.DecimalFormat;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.inject.Inject;

public class SettingActivity extends AppActivity implements ItemInputTextView.OnWholeItemClickListener {
    public static final int NORMAL_USER = 0;//普通用户
    public static final int PURCHASE_USER = 1;//采购商
    public static final int LABOUR_USER = 2;//劳务企业
    public static final int SUPPLIER_USER = 3;//供应商
    private long exitTime;
    private int times;
    private ActivitySettingBinding binding;
    private String shopId;
    long[] mHits = new long[3];
    private int url = 0;//切换测试环境用

    @Inject
    SettingModel viewModel;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
    }

    public static void start(Context context) {
        Intent intent = new Intent();
        intent.setClass(context, SettingActivity.class);
        context.startActivity(intent);
    }

    @Override
    protected void onResume() {
        super.onResume();
        viewModel.getSettingInfo();
    }

    //设置状态栏为暗
    @Override
    protected boolean statusBarDark() {
        return true;
    }

    @Override
    protected void initView() {
        binding = DataBindingUtil.setContentView(SettingActivity.this, R.layout.activity_setting);
        binding.setViewModel(viewModel);
        binding.itvUpdate.setContent(viewModel.getVersionName());
        binding.itvQr.showImgVisible(R.drawable.qrcode);
    }

    public void refreshStatusInfo(SettingInfoEntity settingInfoEntity) {
        binding.itvRePhone.setContent(StringUtil.gonePhone(settingInfoEntity.getMobile()));
        //binding.itvInfo.setContent(settingInfoEntity.getAuthStatus());
        binding.itvBankInfo.setContent(settingInfoEntity.getInvoiceStatus());
    }

    @Override
    protected void init() {
        binding.include.titleView.setText("设置");
        binding.include.rightView.setText("    ");
        binding.include.rightView.setOnClickListener(this);
        binding.include.ivBack.setOnClickListener(this);
        binding.llChangeMobile.setOnClickListener(this);
        binding.llChangePwd.setOnClickListener(this);
        binding.tvLoginOut.setOnClickListener(this);
        binding.itvRePhone.setOnWholeItemClickListener(this);
        binding.itvEditPw.setOnWholeItemClickListener(this);
        binding.itvInfo.setOnWholeItemClickListener(this);
        binding.itvBankInfo.setOnWholeItemClickListener(this);
        binding.itvAddress.setOnWholeItemClickListener(this);
        binding.itvShop.setOnWholeItemClickListener(this);
        binding.itvReceiptInfo.setOnWholeItemClickListener(this);
        binding.itvUpdate.setOnWholeItemClickListener(this);
        binding.itvQr.setOnWholeItemClickListener(this);
        binding.include.titleView.setOnClickListener(this);
        binding.itvPersonInfo.setOnWholeItemClickListener(this);
        binding.itvChange.setOnWholeItemClickListener(this);
        binding.itvChange2.setOnWholeItemClickListener(this);
        binding.itvChange3.setOnWholeItemClickListener(this);
        binding.itvChange4.setOnWholeItemClickListener(this);
        binding.itvFeedback.setOnWholeItemClickListener(this);
        binding.itvCache.setOnWholeItemClickListener(this);
        setAppCache();
        viewModel.getUserInfo();
    }

    @Override
    protected void setupActivityComponent(AppComponent appComponent) {
        DaggerSelfComponent.builder().appComponent(appComponent).selfModule(new SelfModule(this)).build().inject(this);
    }

    @Override
    public void onClick(View v) {
        switch (v.getId()) {
            case R.id.iv_back:
                finish();
                break;

            case R.id.right_view:
                System.arraycopy(mHits, 1, mHits, 0, mHits.length - 1);
                mHits[mHits.length - 1] = SystemClock.uptimeMillis();
                if (mHits[0] >= (mHits[mHits.length - 1] - 500)) {
                    /*AlertDialog.Builder builder = new AlertDialog.Builder(this);
                    EditText editText = new EditText(this);
                    editText.setHint("请输入密码");
                    builder.setView(editText).setPositiveButton("确定", new DialogInterface.OnClickListener() {
                        @Override
                        public void onClick(DialogInterface dialogInterface, int i) {
                            if (editText.getText().toString().equals("000qwer")) {
                                showConfigDialog();
                            } else {
                                MToast.showToast(SettingActivity.this, "输入错误");
                            }
                        }
                    });
                    AlertDialog alertDialog = builder.create();
                    alertDialog.show();*/
                    showTextDialog();
                }

                break;
            case R.id.tv_login_out:
                //弹窗
                showDialog();
//                WebViewX5HostActivity.start(this, "file:///android_asset/dist/index.html");
                break;
            case R.id.title_view:
                // 判断间隔时间 大于2秒就退出应用
                times++;
                if ((System.currentTimeMillis() - exitTime) > 3000) {
                    exitTime = System.currentTimeMillis();
                    times = 0;
                } else if (times > 5) {
                    //    binding.itvStyle.setVisibility(View.VISIBLE);
                    binding.itvChange.setVisibility(View.VISIBLE);
                    binding.itvChange2.setVisibility(View.VISIBLE);
                    binding.itvChange3.setVisibility(View.VISIBLE);
                    binding.itvChange4.setVisibility(View.VISIBLE);
                    //这里写返回后的逻辑（跳到主界面、关闭应用...）
                }
                break;
        }
    }

    private void showConfigDialog() {
        AlertDialog.Builder builder = new AlertDialog.Builder(this);
        EditText editText = new EditText(this);
        editText.setHint("请输入需要配置的手机号");
        builder.setView(editText).setPositiveButton("确定", new DialogInterface.OnClickListener() {
            @Override
            public void onClick(DialogInterface dialogInterface, int i) {
                if (!CheckUtils.isMobileNum(editText.getText().toString())) {
                    MToast.showToast(SettingActivity.this, "请输入正确手机格式");
                } else {
                    viewModel.setIMMobile(editText.getText().toString());
                }
            }
        }).create().show();
    }

    public void companySuccess(String shopId) {
        binding.itvAddress.setVisibility(View.GONE);
        binding.itvBankInfo.setVisibility(View.GONE);
        this.shopId = shopId;
    }

    public void companyFail(String shopId) {
        binding.itvAddress.setVisibility(View.GONE);
        binding.itvBankInfo.setVisibility(View.GONE);
        this.shopId = shopId;
    }

    private void showDialog() {
        View view = View.inflate(getActivity(), R.layout.dialog_two_btn, null);
        final RoundCornerDialog roundCornerDialog = new RoundCornerDialog(getActivity(), 0, 0, view, R.style.RoundCornerDialog);
        roundCornerDialog.show();
        roundCornerDialog.setCanceledOnTouchOutside(false);// 设置点击屏幕Dialog不消失
        //roundCornerDialog.setOnKeyListener(keylistener);//设置点击返回键Dialog不消失

        TextView tv_message = view.findViewById(R.id.tv_message);
        TextView tv_logout_confirm = view.findViewById(R.id.tv_logout_confirm);
        TextView tv_logout_cancel = view.findViewById(R.id.tv_logout_cancel);
        tv_message.setText("确定退出登录");

        //确定
        tv_logout_confirm.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                SharedPreferenceUtil.getInstance().saveString("EVENT_SHOPPING_TYPE", "");
                //请求接口
//                String token = SharedPreferenceUtil.getInstance().getSaveStringData(SharedPreferenceUtil.LOGIN_TOKEN, "");
//                viewModel.loginOutModel(token);
                viewModel.loginOut();
                roundCornerDialog.dismiss();

            }
        });
        //取消
        tv_logout_cancel.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                roundCornerDialog.dismiss();
            }
        });
    }

    private void showTextDialog() {
        View view = View.inflate(getActivity(), R.layout.dialog_text_btn, null);
        final RoundCornerDialog roundCornerDialog = new RoundCornerDialog(getActivity(), 0, 0, view, R.style.RoundCornerDialog);
        roundCornerDialog.show();
        roundCornerDialog.setCanceledOnTouchOutside(false);// 设置点击屏幕Dialog不消失
        //roundCornerDialog.setOnKeyListener(keylistener);//设置点击返回键Dialog不消失

        EditText et_content = view.findViewById(R.id.et_content);
        TextView tv_title = view.findViewById(R.id.tv_title);
        TextView tv_logout_confirm = view.findViewById(R.id.tv_logout_confirm);
        TextView tv_logout_cancel = view.findViewById(R.id.tv_logout_cancel);
        et_content.setHint("请输入密码");
        tv_title.setText("切换环境");

        //确定
        tv_logout_confirm.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                if (et_content.getText().toString().equals("000qwer")) {
                    setUrl();
                }
                roundCornerDialog.dismiss();

            }
        });
        //取消
        tv_logout_cancel.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                roundCornerDialog.dismiss();
            }
        });
    }

    public void loginOutSucceed() {
        //退出登录后清空用户状态信息
        IMUtils.getInstance().clearLoginUserInfo();
        EventBus.getDefault().post(MachinePublishEvent.make().setMessageTag(EventConstant.EVENT_LOGIN_OUT));
        EventBus.getDefault().postSticky(LoginEvent.make(EventConstant.EVENT_LOGIN_OUT, ""));
        EventBus.getDefault().postSticky(ChooseAreaEvent.make(EventConstant.EVENT_MENU_DEVICE_OUT, ""));
        //通知大首页刷新数据
        EventBus.getDefault().postSticky(new RefreshHomeNoticeEVent(EventConstant.EVENT_NOTICE_REFRESH_HOME));
        Preferences.saveUserToken("");
        Preferences.saveUserAccount("");
        finish();
    }

    @Override
    public void OnWholeItemClick(View view) {
        switch (view.getId()) {
            case R.id.itv_re_phone:
                Intent intent = new Intent(SettingActivity.this, ChangeMobileActivity.class);
                startActivity(intent);
                break;
            case R.id.itv_edit_pw:
                Intent intentPwd = new Intent(SettingActivity.this, ChangePwdActivity.class);
                startActivity(intentPwd);
                break;
            case R.id.itv_address:
                Intent intentAddress = new Intent(SettingActivity.this, AddressActivity.class);
                startActivity(intentAddress);
                break;
            case R.id.itv_bank_info:
                Intent intentBank = new Intent(SettingActivity.this, BankInfoActivity.class);
                startActivity(intentBank);
                break;
            case R.id.itv_shop:
//                ShopInfoActivity.start(SettingActivity.this,shopId);
//                CompanyPersonCardActivity.start(SettingActivity.this,"");
                CompanyShopInfoActivity.start(SettingActivity.this, shopId);
                break;
            /*case R.id.itv_receipt_info:
                ReceiptInfoActivity.start(this, "");
                break;*/

            case R.id.itv_info:
                AuthActivity.start(this);
                break;

            case R.id.itv_update:
                UpdateUtils.getInstance().getNewVersion(this, true);
                break;

            case R.id.itv_qr:
//                viewModel.getQrInfo();
                SelfQrCodeActivity.start(SettingActivity.this);
                break;
            case R.id.itv_person_info:
//                viewModel.getQrInfo();
                SelfQrCodeActivity.start(SettingActivity.this);
                break;
            case R.id.itv_change:
                viewModel.loginOut();
                APIManager.getInstance().changeAPIManager("http://liqiao.ngrok.gcw.net:90/");
                Toast.makeText(getActivity(), "切换到李乔环境", Toast.LENGTH_SHORT).show();
                break;
            case R.id.itv_change2:
                viewModel.loginOut();
                APIManager.getInstance().changeAPIManager("http://api.sgbwl.com/sgb-app/");
                Toast.makeText(getActivity(), "切换到测试环境", Toast.LENGTH_SHORT).show();
                break;
            case R.id.itv_change3:
                viewModel.loginOut();
//                APIManager.getInstance().changeAPIManager("http://app.shigongbang.com:9091/");
                APIManager.getInstance().changeAPIManager("http://gateway.shigongbang.com/sgb-app-pre/");
                Toast.makeText(getActivity(), "切换到预发布环境", Toast.LENGTH_SHORT).show();
                break;
            case R.id.itv_change4:
                viewModel.loginOut();
//                APIManager.getInstance().changeAPIManager("http://app.shigongbang.com/");
                APIManager.getInstance().changeAPIManager("http://gateway.shigongbang.com/sgb-app-android/");
                Toast.makeText(getActivity(), "切换到正式环境", Toast.LENGTH_SHORT).show();
                break;
            case R.id.itv_feedback://意见反馈
                FeedbackActivity.start(getActivity());
                break;
            case R.id.itv_cache://清空缓存
                DialogHelper.showDialog(this, "提示", "确定清空缓存？", "确定", new DialogFunction() {
                    @Override
                    public void normalRoundDialog() {

                        clearAppCache(SettingActivity.this);
                    }
                });
                break;
        }
    }


    /**
     * 获取app的缓存大小
     * 1. 录制的视频/storage/emulated/0/xueliangapp/video/1573972925136.mp4
     * 2. 录制的音频/storage/emulated/0/xueliangapp/radio/1573972925136.amr
     * 3. 下载的更新包/storage/emulated/0/Android/data/com.sdxzt.xueliangapp_v3/files/Download/xueliang_update.apk
     * 4. 缓存/storage/emulated/0/Android/data/com.sdxzt.xueliangapp_v3/cache
     */
    File videoDir, radioDir, filesDir, cacheDir;

    private String getAppCache() {
        long fileSize = 0;
        String cacheSize = "0KB";
        videoDir = new File(Environment.getExternalStorageDirectory() + "/xueliangapp/video");
        Log.d("TAG", "getAppCache: videoDir大小: " + getDirSize(videoDir));
        radioDir = new File(Environment.getExternalStorageDirectory() + "/xueliangapp/radio");
        Log.d("TAG", "getAppCache: radioDir大小: " + getDirSize(radioDir));
        filesDir = getActivity().getExternalFilesDir(Environment.DIRECTORY_DOWNLOADS);
        Log.d("TAG", "getAppCache: filesDir大小: " + getDirSize(filesDir));
        ///storage/emulated/0/Android/data/com.sdxzt.xueliangapp_v3/files,这里面有download文件夹,里面是下载的更新包
        cacheDir = getActivity().getExternalCacheDir();
        Log.d("TAG", "getAppCache: cacheDir大小: " + getDirSize(cacheDir));
        ///storage/emulated/0/Android/data/com.sdxzt.xueliangapp_v3/cache
//        fileSize += getDirSize(getActivity().getFilesDir());
        fileSize += getDirSize(getActivity().getCacheDir());//这行是默认的缓存地址,看图片什么的会在这里积累缓存
        fileSize += getDirSize(videoDir);
        fileSize += getDirSize(radioDir);
        fileSize += getDirSize(filesDir);
        fileSize += getDirSize(cacheDir);
        String fileSizeStr = formatFileSize(fileSize);
        Log.d("TAG", "getAppCache: 总缓存大小: " + fileSizeStr);
        return fileSizeStr;
    }

    /**
     * 获取文件大小(字节为单位)
     *
     * @param dir
     * @return
     */
    private long getDirSize(File dir) {
        if (dir == null) {
            return 0;
        }
        if (!dir.isDirectory()) {
            return 0;
        }
        long dirSize = 0;
        File[] files = dir.listFiles();
        for (File file : files) {
            if (file.isFile()) {
                dirSize += file.length();//文件的长度就是文件的大小
            } else if (file.isDirectory()) {
                dirSize += file.length();
                dirSize += getDirSize(file); // 递归调用继续统计
            }
        }
        return dirSize;
    }

    /**
     * 格式化文件长度
     *
     * @param fileSize
     * @return
     */
    private String formatFileSize(long fileSize) {
        DecimalFormat df = new DecimalFormat("#0.00");//表示小数点前至少一位,0也会显示,后保留两位

        String fileSizeString = "";
        if (fileSize < 1024) {
            fileSizeString = df.format((double) fileSize) + "B";
        } else if (fileSize < 1048576) {
            fileSizeString = df.format((double) fileSize / 1024) + "KB";
        } else if (fileSize < 1073741824) {
            fileSizeString = df.format((double) fileSize / 1048576) + "MB";
        } else {
            fileSizeString = df.format((double) fileSize / 1073741824) + "G";
        }
        return fileSizeString;
    }

    private void setAppCache() {
        String fileSize = getAppCache();
        binding.itvCache.getContent_edt().setText(fileSize);
        Log.d("TAG", "setAppCache: 重新显示缓存大小");
        Log.d("TAG", "setAppCache: 当前缓存" + fileSize);
    }

    public void clearAppCache(final Activity activity) {

        final Handler handler = new Handler() {
            @SuppressLint("HandlerLeak")
            @Override
            public void handleMessage(@NonNull Message msg) {
                super.handleMessage(msg);
                Log.d("TAG", "handlerMessage: ");
                if (msg.what == 1) {
                    setAppCache();
                    MToast.showToast(getActivity(), "清空成功");
                } else {
                    MToast.showToast(getActivity(), "清空失败");
                }
            }
        };

        new Thread(new Runnable() {
            @Override
            public void run() {
                Log.d("TAG", "run: ");
                Message msg = new Message();
                try {
                    clearCacheFolder(videoDir, System.currentTimeMillis());
                    clearCacheFolder(radioDir, System.currentTimeMillis());
                    clearCacheFolder(filesDir, System.currentTimeMillis());
                    clearCacheFolder(cacheDir, System.currentTimeMillis());
                    msg.what = 1;
                } catch (Exception e) {
                    e.printStackTrace();
                    msg.what = -1;
                }
                handler.sendMessage(msg);
            }
        }).start();
    }


    /**
     * 清除缓存目录
     *
     * @param dir     目录
     * @param curTime 当前系统时间
     */
    private int clearCacheFolder(File dir, long curTime) {
        int deletedFiles = 0;
        if (dir != null && dir.isDirectory()) {
            try {
                for (File child : dir.listFiles()) {
                    if (child.isDirectory()) {
                        deletedFiles += clearCacheFolder(child, curTime);
                    }
                    if (child.lastModified() < curTime) {
                        if (child.delete()) {
                            deletedFiles++;
                        }
                    }
                }
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
        Log.d("TAG", "clearCacheFolder: 清除目录: " + dir.getAbsolutePath());
        return deletedFiles;
    }

    public void showQRCode(String imAccount) {
        ImageView imageView = new ImageView(this);
        imageView.setImageBitmap(createQRCode(imAccount));
        imageView.setPadding(0, 0, 0, ScreenUtil.dip2px(80));
        AlertDialog.Builder builder = new AlertDialog.Builder(this);
        builder.setView(imageView).setTitle(viewModel.userInfo.get().getUsername()).setMessage("扫二维码添加我为好友吧").create().show();
    }

    private Bitmap createQRCode(String s) {
        int width = 600;
        int height = 600;
        QRCodeWriter qrCodeWriter = new QRCodeWriter();
        Map<EncodeHintType, String> hints = new HashMap<>();
        hints.put(EncodeHintType.CHARACTER_SET, "utf-8"); //记得要自定义长宽
        BitMatrix encode = null;
        try {
            encode = qrCodeWriter.encode(s, BarcodeFormat.QR_CODE, width, height, hints);
        } catch (WriterException e) {
            e.printStackTrace();
        }
        int[] colors = new int[width * height];
        //利用for循环将要表示的信息写出来
        for (int i = 0; i < width; i++) {
            for (int j = 0; j < height; j++) {
                if (encode.get(i, j)) {
                    colors[i * width + j] = Color.BLACK;
                } else {
                    colors[i * width + j] = Color.WHITE;
                }
            }
        }
        return Bitmap.createBitmap(colors, width, height, Bitmap.Config.RGB_565);
    }

    //设置地址
    public void setUrl() {
        UrlSelectEntity url1 = new UrlSelectEntity();
        UrlSelectEntity url2 = new UrlSelectEntity();
        UrlSelectEntity url3 = new UrlSelectEntity();
        UrlSelectEntity url4 = new UrlSelectEntity();
        UrlSelectEntity url5 = new UrlSelectEntity();
        UrlSelectEntity url6 = new UrlSelectEntity();
        UrlSelectEntity url7 = new UrlSelectEntity();
        List<UrlSelectEntity> list = new ArrayList<>();
        url1.setUrl("http://app.gcw.net:9090/");
        url2.setUrl("http://app.shigongbang.com/");
        url3.setUrl("http://app.shigongbang.com:9091/");
        url4.setUrl("http://qiupengwei.ngrok.gcw.net:90/");
        url5.setUrl("http://swj.ngrok.gcw.net:90/");
        url6.setUrl("http://liqiao.ngrok.gcw.net:90/");
        url7.setUrl("http://app.ngrok.gcw.net:90/");
        list.add(url1);
        list.add(url2);
        list.add(url3);
        list.add(url4);
        list.add(url5);
        list.add(url6);
        list.add(url7);
        showUrlPop(list);
    }

    private void showUrlPop(List<UrlSelectEntity> list) {
        OptionsPickerView businessOption = new OptionsPickerBuilder(SettingActivity.this, (options1, options2, options3, v) -> {
            String content = list.get(options1).getUrl();
            SharedPreferenceUtil.init(SettingActivity.this);
            SharedPreferenceUtil.getInstance().saveData(SharedPreferenceUtil.URL, content);
            Toast.makeText(SettingActivity.this, "选择成功，请重新进入APP", Toast.LENGTH_LONG).show();
        }).build();
        businessOption.setPicker(list);
        businessOption.show();
    }
}
